<?php

namespace Api\Controller;

use Think\Controller;
use Wechat\WechatApi;
use Think\Crypt;
use Utuo\Base62;
use Api\Tools\QrcodeUtil;
use Utuo\WechatAdvance\QrCode;

class TestController extends Controller {
	public function indexAction() {
		$wechat = new WechatApi ( 'test' );
		$content = $wechat->getContent ();
		if ($content == 'text') {
			$wechat->responseText ( $content );
		} elseif ($content == 'news') {
			$data = array (
					array (
							'Title' => 'title',
							'Description' => 'description',
							'PicUrl' => 'http://wmei-wmei5.stor.sinaapp.com/2014-03-08/2014030817103778923331.jpg',
							'Url' => 'http://baidu.com' 
					) ,
					array (
							'Title' => 'title',
							'Description' => 'description',
							'PicUrl' => 'http://wmei-wmei5.stor.sinaapp.com/2014-03-08/2014030817103778923331.jpg',
							'Url' => 'http://baidu.com' 
					) ,
			);
			$wechat->responseNews ( $data );
		} elseif ($content == 'music'){
			$wechat->responseMusic('我们好像在哪见过', '你还记得吗', 'http://5.wmei.sinaapp.com/music.mp3', 'http://5.wmei.sinaapp.com/music.mp3');
		} elseif ($content == 'onenews'){
			$wechat->responseSingleNews('高圆圆', '完美女神', 'http://wmei-wmei5.stor.sinaapp.com/2014-03-08/2014030817103778923331.jpg', 'http://www.baidu.com');
		}
	}
	
	public function testAction(){
		$id = 1;
		$key = 'utuo88';
		$id2 = Crypt::encrypt($id, $key);
		$id3 = Crypt::decrypt($id2, $key);
		
		dump($id2);
		dump($id3);
		
		$n = I('n');
		$n1 = Base62::encode($n);
		$n2 = Base62::decode($n1);
		dump($n1);
		dump($n2);
		dump(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'));
	}
	
}